<?php
class ScorringCommand extends CConsoleCommand
{
	public function run($array)
	{
		$all_scorring = Credits::model()->findAll('status = :s', array(':s' => Credits::STATUS_SCORRING));

		foreach($all_scorring as $item)
			if(!is_null($result = $this->_getScorring($item->id)))
				Credits::model()->updateByPk($item->id, array('status' => Credits::STATUS_NEW_SCORRING, 'scorring_ball' => $result));
	}

	private function _getScorring($id)
	{
		return mt_rand(1,10);
	}

}